package org.learn.dataguru.kafka.demo.class02;

import kafka.producer.Partitioner;
import kafka.utils.VerifiableProperties;

/**
 * 随机分区
 * @author serenity
 *
 */
public class RandomPartitioner implements Partitioner {

	public RandomPartitioner(VerifiableProperties verifiableProperties) {
		
	}

	public int partition(Object key, int numPartitions) {
		 System.out.println(Thread.currentThread().getId() + "," +this.toString());
		 return (int)Math.floor(Math.random() * numPartitions);
	}

}
